﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Microsoft.IT.Crm.Utility.CrmSolutionManager
{
    public class ServiceInformation
    {
        public string Domain;
        public string Username;
        public string Password;

        private string OrganizationServer;
        private string Port;
        private bool SSL;

        public string OrganizationName;

        public string OrganizationServiceUrl
        {
            get
            {
                return string.Format("{0}://{1}:{2}", SSL ? "https" : "http", OrganizationServer, Port);
            }
        }

        public ServiceInformation()
        {
            Domain = CRMSolutionManagerConfig.Instance.RunAsAccount != null ? CRMSolutionManagerConfig.Instance.RunAsAccount.Domain : string.Empty;
            Username = CRMSolutionManagerConfig.Instance.RunAsAccount != null ? CRMSolutionManagerConfig.Instance.RunAsAccount.Username : string.Empty;
            Password = CRMSolutionManagerConfig.Instance.RunAsAccount != null ? CRMSolutionManagerConfig.Instance.RunAsAccount.Password : string.Empty;

            OrganizationServer = CRMSolutionManagerConfig.Instance.ServerName;
            Port = CRMSolutionManagerConfig.Instance.ServerPort;
            OrganizationName = CRMSolutionManagerConfig.Instance.OrganizationName;

            SSL = CRMSolutionManagerConfig.Instance.UsingSSL;
        }
    }
}
